package com.arnold.demo.journal.main

import com.arnold.demo.journal.config.Config
import org.apache.spark.sql.{DataFrame, SparkSession}
import org.apache.kudu.spark.kudu._

/**
  * Created by arnold.zhu on 2017/7/23.
  */
object SearchKudu {

  private val sparkSession = SparkSession.builder.
    master("local")
    .appName("WXPay")
    .getOrCreate()

  private val kuduOptions = Map("kudu.master" -> Config.KUDU_MASTER, "kudu.table" -> "kudu_invoices")

  def main(args: Array[String]): Unit = {
    search(sparkSession)
  }

  def search(sparkSession: SparkSession): Unit = {
    sparkSession.read.options(kuduOptions).kudu.createOrReplaceTempView("kudu_invoices")

    val df: DataFrame = sparkSession.sql("select * from kudu_invoices")

    println(df.sort("id").count())
  }


}
